home *** CD-ROM | disk | FTP | other *** search
/ BBS in a Box 7 / BBS in a Box - Macintosh - Volume VII (BBS in a Box) (January 1993).iso / Files / Prog / T / TC Prog Guide.cpt / picture ƒ / ring.c < prev    next >
Text File  |  1990-11-08  |  1KB  |  63 lines

  1. /*
  2. *    FILE:        ring.c
  3. *    AUTHOR:        R. Gonzalez
  4. *    CREATED:    October 8, 1990
  5. *
  6. *    defines methods for ring nested segment
  7. */
  8.  
  9. # include    "ring.h"
  10. # include    "trans.h"
  11. # include    "cube.h"
  12.  
  13. # define    NUM_CUBES    8
  14. # define    RADIUS        3.
  15. # define    CUBE_TYPE    Fast_Cube
  16.  
  17. /******************************************************************
  18. *    initialize
  19. ******************************************************************/
  20. boolean    Ring::init(void)
  21. {
  22.     int                i;
  23.     Translation        *transl;
  24.     Rotation_Y        *roty;
  25.     Transformation    *combination;
  26. /*    The following temp is needed due to a bug in Think C when
  27.     handling arrays of pointers, when the array is an instance var.
  28. */
  29.     Segment            *temp_seg;
  30.     
  31.     Nested_Segment::init();
  32.     
  33.     transl = new(Translation);
  34.     transl->init();
  35.     transl->set(-.5,-.5,RADIUS-.5);
  36.     roty = new(Rotation_Y);
  37.     roty->init();
  38.     combination = new(Transformation);
  39.     combination->init();
  40.     
  41.     num_segments = NUM_CUBES;
  42.     
  43.     for (i=0 ; i<NUM_CUBES ; i++)
  44.     {
  45.         temp_seg = new(CUBE_TYPE);
  46.         segment[i] = temp_seg;
  47.         segment[i]->init();
  48.         roty->set(i*2.*PI/NUM_CUBES);
  49.         combination->combine(transl,roty);
  50.         segment[i]->move(combination);
  51.     }
  52.     
  53.     transl->destroy();
  54.     delete(transl);
  55.     roty->destroy();
  56.     delete(roty);
  57.     combination->destroy();
  58.     delete(combination);
  59.     
  60.     return TRUE;
  61. }
  62.  
  63.